Page({

  /**
   * 页面的初始数据
   */
  imgWidth: 0,
  imgHeight: 0,
  screenWidth: 0,
  data: {
    url_path: "",
    showWidth: 0,
    showHeight: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.screenWidth = wx.getSystemInfoSync().screenWidth
    var url_path = options.url_path;
    if (options.isescape == '1') {
      url_path = decodeURIComponent(url_path);
      console.log(url_path)
    }
    wx.showLoading({title: '正在加载...'})
    wx.getImageInfo({
      src: url_path,
      success: (res) => {
        console.log('res', res)
        this.imgWidth = res.width,
        this.imgHeight = res.height
        this.setData({
          url_path: url_path,
          showWidth: this.screenWidth,
          showHeight: this.screenWidth * this.imgHeight / this.imgWidth
        });
      }
    })
    this.title = options.title
  },
  loaded () {
    wx.hideLoading()
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    if (this.title) {
      setTimeout(() => {
        wx.setNavigationBarTitle({
          title: this.title,
          success: function() {
            console.log('重置标题成功了');
          }
        })
      }, 1000)
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})